package com.ruoyi.cost.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cost.domain.AccGenLedgerBasicIn;
import com.ruoyi.cost.service.IAccGenLedgerBasicInService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 总账基础信息Controller
 * 
 * @author 王志旸
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/cost/in")
public class AccGenLedgerBasicInController extends BaseController
{
    @Autowired
    private IAccGenLedgerBasicInService accGenLedgerBasicInService;

    /**
     * 查询总账基础信息列表
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccGenLedgerBasicIn accGenLedgerBasicIn)
    {
        startPage();
        List<AccGenLedgerBasicIn> list = accGenLedgerBasicInService.selectAccGenLedgerBasicInList(accGenLedgerBasicIn);
        return getDataTable(list);
    }

    /**
     * 导出总账基础信息列表
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:export')")
    @Log(title = "总账基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccGenLedgerBasicIn accGenLedgerBasicIn)
    {
        List<AccGenLedgerBasicIn> list = accGenLedgerBasicInService.selectAccGenLedgerBasicInList(accGenLedgerBasicIn);
        ExcelUtil<AccGenLedgerBasicIn> util = new ExcelUtil<AccGenLedgerBasicIn>(AccGenLedgerBasicIn.class);
        util.exportExcel(response, list, "总账基础信息数据");
    }

    /**
     * 获取总账基础信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:query')")
    @GetMapping(value = "/{structuralDelimiter}")
    public AjaxResult getInfo(@PathVariable("structuralDelimiter") String structuralDelimiter)
    {
        return success(accGenLedgerBasicInService.selectAccGenLedgerBasicInByStructuralDelimiter(structuralDelimiter));
    }

    /**
     * 新增总账基础信息
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:add')")
    @Log(title = "总账基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccGenLedgerBasicIn accGenLedgerBasicIn)
    {
        return toAjax(accGenLedgerBasicInService.insertAccGenLedgerBasicIn(accGenLedgerBasicIn));
    }

    /**
     * 修改总账基础信息
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:edit')")
    @Log(title = "总账基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccGenLedgerBasicIn accGenLedgerBasicIn)
    {
        return toAjax(accGenLedgerBasicInService.updateAccGenLedgerBasicIn(accGenLedgerBasicIn));
    }

    /**
     * 删除总账基础信息
     */
//    @PreAuthorize("@ss.hasPermi('cost:in:remove')")
    @Log(title = "总账基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{structuralDelimiters}")
    public AjaxResult remove(@PathVariable String[] structuralDelimiters)
    {
        return toAjax(accGenLedgerBasicInService.deleteAccGenLedgerBasicInByStructuralDelimiters(structuralDelimiters));
    }
}
